<?php
/**
 * Created by PhpStorm.
 * User: dehong
 * Date: 2016/9/16
 * Time: 19:43
 */
session_start();
// 定义个常量，用来调用includes里面的文件
define('IN_TG',true);
// 用来指定本页内容
define('SCRIPT','blog');
// 引入公共文件
require dirname(__FILE__).'/includes/common.inc.php'; // 转换成硬路径,速度更快
// 分页模块
global $_pagesize,$_pagenum;
_page("SELECT tg_id FROM tg_user",$_system['blog']); //第一个参数取总条数，第二个参数指定每页多少条
// 从数据库提取数据获取结果集
$_sql = "SELECT tg_id,tg_username,tg_face,tg_sex FROM tg_user ORDER BY tg_reg_time DESC LIMIT $_pagenum,$_pagesize";
$result = _fetch_array_list($_sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?php require ROOT_PATH.'includes/title.inc.php'; ?>
    <script type="text/javascript" src="js/blog.js"></script>
</head>
<body>
<?php require ROOT_PATH."includes/header.inc.php"; ?>
    <div id="blog">
        <h2>博友列表</h2>
        <?php
            $_html = array();
            foreach($result as $_rows){
                $_html['id'] = $_rows['tg_id'];
                $_html['username'] = $_rows['tg_username'];
                $_html['face'] = $_rows['tg_face'];
                $_html['sex'] = $_rows['tg_sex'];
                $_html = _html($_html);
            ?>
        <dl>
            <dd class="user"><?php echo $_html['username'];?>(<?php echo $_html['sex'];?>)</dd>
            <dt><img src="<?php echo $_html['face'];?>" alt="<?php echo $_html['username'];?>" /></dt>
            <dd class="message"><a href="javascript:;" name="message" title="<?php echo $_html['id'];?>">发消息</a></dd>
            <dd class="friend"><a href="javascript:;" name="friend" title="<?php echo $_html['id'];?>">加为好友</a></dd>
            <dd class="guest">写留言</dd>
            <dd class="flower"><a href="javascript:;" name="flower" title="<?php echo $_html['id'];?>">给他送花</a></dd>
        </dl>
        <?php }
        // 调用分页 1|2 1表示数字分页，2表示文本分页
        _paging(1);
        ?>
    </div>
<?php require ROOT_PATH."includes/footer.inc.php"; ?>
</body>
</html>
